<?php

/**
 * This is the model class for table "tg_Poster".
 *
 * The followings are the available columns in table 'tg_Poster':
 * @property integer $ID
 * @property integer $UID
 * @property string $Title
 * @property string $Url
 * @property integer $Size
 * @property integer $Position
 * @property string $Path
 * @property string $Filename
 * @property string $Thumb
 * @property integer $Click
 * @property integer $Status
 * @property string $Addtime
 */
class Poster extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Poster the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tg_Poster';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('UID, Title, Url, Position, Path, Filename, Addtime', 'required'),
			array('UID, Size, Position, Click, Status', 'numerical', 'integerOnly'=>true),
			array('Title', 'length', 'max'=>64),
			array('Url', 'length', 'max'=>256),
			array('Path, Thumb', 'length', 'max'=>255),
			array('Filename', 'length', 'max'=>32),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID, UID, Title, Url, Size, Position, Path, Filename, Thumb, Click, Status, Addtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID' => 'ID',
			'UID' => 'Uid',
			'Title' => 'Title',
			'Url' => 'Url',
			'Size' => 'Size',
			'Position' => 'Position',
			'Path' => 'Path',
			'Filename' => 'Filename',
			'Thumb' => 'Thumb',
			'Click' => 'Click',
			'Status' => 'Status',
			'Addtime' => 'Addtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID',$this->ID);
		$criteria->compare('UID',$this->UID);
		$criteria->compare('Title',$this->Title,true);
		$criteria->compare('Url',$this->Url,true);
		$criteria->compare('Size',$this->Size);
		$criteria->compare('Position',$this->Position);
		$criteria->compare('Path',$this->Path,true);
		$criteria->compare('Filename',$this->Filename,true);
		$criteria->compare('Thumb',$this->Thumb,true);
		$criteria->compare('Click',$this->Click);
		$criteria->compare('Status',$this->Status);
		$criteria->compare('Addtime',$this->Addtime,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}